//
//  ViewController.m
//  time
//
//  Created by XXX on 2017/5/3.
//  Copyright © 2017年 lee. All rights reserved.
//

#import "ViewController.h"

#import "TimeView.h"

@interface ViewController (){
    TimeView *timeV;
}

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    NSLog(@"show time");
    
    timeV = [[TimeView alloc]initWithFrame:CGRectMake((self.view.frame.size.width-150)/2, 100, 150, 150)];
    [self.view addSubview:timeV];
    
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake((self.view.frame.size.width-60)/2, 350, 60, 30)];
    [button setTitle:@"更换主题" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:11];
    [button addTarget:self action:@selector(chooseAction:) forControlEvents:UIControlEventTouchUpInside];
    button.layer.borderColor = [UIColor blackColor].CGColor;
    button.layer.borderWidth = 1;
    button.layer.cornerRadius = 5;
    [self.view addSubview:button];
}

-(void)chooseAction:(id)sender{
    UIAlertController *alert = [[UIAlertController alloc]init];
    UIAlertAction *cancelAction =  [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    UIAlertAction *firstAction =  [UIAlertAction actionWithTitle:@"简约清新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [timeV changeStyle:0];
    }];
    UIAlertAction *secondAction =  [UIAlertAction actionWithTitle:@"黝黑夜光" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [timeV changeStyle:1];
    }];
    UIAlertAction *thirdAction =  [UIAlertAction actionWithTitle:@"沉稳商务" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [timeV changeStyle:2];
    }];
    [alert addAction:cancelAction];
    [alert addAction:firstAction];
    [alert addAction:secondAction];
    [alert addAction:thirdAction];
    
    [self presentViewController:alert animated:YES completion:nil];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
